import React, { memo, useCallback, useState } from 'react'

const Son = memo(props => {
  console.log('123456')
  const doSomeThing = () => {
    props.doSomeThing(1)
  }
  return <button onClick={doSomeThing}>按钮</button>
})

export default function UseCallback() {
  const [num, setNum] = useState(1) 
  const doSomeThing = useCallback(val => setNum(num => num + val), [])
  return (
    <div>
      <h1>{num}</h1>
      <br />
      <Son doSomeThing={doSomeThing} />
    </div>
  )
}
